<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>0.5实现watcher</title>
</head>
<script src="./testIndex.js"></script>
<body>
    
</body>
</html>

<script>
    let vm = new Vue({
        data: {
            userName: '蒋皓天',
            sex: 'male',
            wife: {
                userName: '周钰',
                sex: 'female'
            }
        },
        watch: {
            userName() {
                console.log('更新1')
            },
            'wife.userName':function(newValue, oldValue) {
                console.log('更新2:', newValue, oldValue)
            }
        }
    })
    vm.userName = 'jht'
    vm.wife.userName = 'zy'
    console.log('vm:', vm);
</script>